package com.levi.config;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.levi.interceptor.UserLoginInterceptor;
import com.levi.pojo.User;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;
import java.util.List;

/**
 * @author shentong
 * @since 2022/3/24 8:51 PM
 * 用户登录拦截器配置类
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] excludeArr = {"/error","/user/login", "/user/register", "/categories", "/products","/products/*","/pay/*"};
        List<String> excludeList = Arrays.asList(excludeArr);
        registry.addInterceptor(new UserLoginInterceptor())
                //哪些路径不进行拦截
                .excludePathPatterns(excludeList)
                //拦截所有路径
                .addPathPatterns("/**");
    }
}
